package com.bush.mall.coupon.controller;

import org.springframework.web.bind.annotation.*;
import com.bush.mall.common.entity.Result;;
import com.bush.mall.coupon.entity.CouponSpuRelationEntity;
import com.bush.mall.coupon.service.CouponSpuRelationService;
import javax.annotation.Resource;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 优惠券与产品关联
 * @author RUN
 * @date 2022-11-29
 */
@RestController
@RequestMapping("couponspurelation")
@Api(tags = "优惠券与产品关联管理" )
public class CouponSpuRelationController {

    @Resource(name= CouponSpuRelationService.BEAN_ID)
    private CouponSpuRelationService couponSpuRelationService;

    /**
     * 分页查询优惠券与产品关联列表
     * @author RUN
     * @date 2022-11-29
     */
    @ApiOperation(value = "分页查询优惠券与产品关联列表")
    @GetMapping("queryForPage")
    public Result queryForPage(Integer current,Integer size){
        return couponSpuRelationService.queryForPage(current,size);
    }

    /**
     * 保存优惠券与产品关联表单
     * @author RUN
     * @date 2022-11-29
     */
    @ApiOperation(value = "保存优惠券与产品关联表单")
    @PostMapping
    public Result saveCouponSpuRelation(@RequestBody CouponSpuRelationEntity couponSpuRelation){
        return couponSpuRelationService.saveCouponSpuRelation(couponSpuRelation);
    }

    /**
     * 修改优惠券与产品关联表单
     * @author RUN
     * @date 2022-11-29
     */
    @ApiOperation(value = "修改优惠券与产品关联表单")
    @PutMapping
    public Result updateCouponSpuRelation(@RequestBody CouponSpuRelationEntity couponSpuRelation){
        return couponSpuRelationService.updateCouponSpuRelation(couponSpuRelation);
    }

    /**
     * 通过指定id删除优惠券与产品关联
     * @author RUN
     * @date 2022-11-29
     */
    @ApiOperation(value = "通过指定id删除优惠券与产品关联")
    @DeleteMapping
    public Result deleteCouponSpuRelation(Long id){
        return couponSpuRelationService.deleteCouponSpuRelation(id);
    }

}
